package com.eling.elcms.travel.model;

import com.eling.elcms.basedoc.model.EnumSerializer;
import com.eling.elcms.core.dao.annotation.Between;
import com.eling.elcms.core.dao.annotation.CriteriaEnhancer;
import com.eling.elcms.core.dao.annotation.CriteriaEnhancers;
import com.eling.elcms.core.dao.annotation.In;
import com.eling.elcms.core.dao.hibernate.OrderCriteriaEnhancer;
import com.eling.elcms.core.dao.hibernate.search.EnumBridge;
import com.eling.elcms.core.model.BaseModel;
import com.eling.elcms.ordermanager.model.ServicePoint;
import com.eling.elcms.privilege.service.impl.CommonPrivilegeCriteriaEnhancer;
import com.eling.elcms.system.model.CommonUser;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.hibernate.search.annotations.*;

import javax.persistence.*;
import java.util.Date;
/**
 *  入住登记   linjizeng
 *  
 */
@Entity
@Table(name = "travel_checkin")
@Indexed
@CriteriaEnhancers(criteriaEnhancers = {
		@CriteriaEnhancer(impl = OrderCriteriaEnhancer.class),
		@CriteriaEnhancer(impl = CommonPrivilegeCriteriaEnhancer.class, parameter = "servicepoint:servicePoint") })
public class CheckIn extends BaseModel{

	private static final long serialVersionUID = -1920004873586284949L;
	
	@Id
	@DocumentId
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Long pkCheckIn;
	
	/** 所属服务点*/
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "pkServicePoint")
    @IndexedEmbedded(depth = 1)
	private ServicePoint servicePoint;
	
	/** 预约*/
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "pkCheckInImplement")
    @IndexedEmbedded(depth = 1)
	private CheckInImplement checkInImplement;
	
	/** 房间*/
	@OneToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "pkRoomRegister")
    @IndexedEmbedded(depth = 1)
	private RoomRegister roomRegister;
	
	/** 登记日期 */
	@Column
	@Field
	@Between
	private Date registerDate;
	
	/** 入住日期 */
	@Column
	@Field
	@Between
	private Date checkInDate;
	
	/** 退住日期 */
	@Column
	@Field
	@Between
	private Date checkOutDate;
	
	/** 登记人 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "operator")
	@IndexedEmbedded(depth = 1)
	private CommonUser operator;
	
	/** 登记状态*/
	@Enumerated(EnumType.STRING)
	@In	
	@FieldBridge(impl = EnumBridge.class)
	private Status status;
	
	/** 查房状态*/
	@Enumerated(EnumType.STRING)
	@In	
	@FieldBridge(impl = EnumBridge.class)
	private CheckOutStatus checkOutStatus;
	
	@Version
	private Integer version;
	
	@JsonSerialize(using = EnumSerializer.class)
	public static enum CheckOutStatus {
		NoCheckOut("未查房"),CheckOut("已查房");

		private String display;
		CheckOutStatus(String display) {
			this.display = display;
		}
		public String getDisplay() {
			return display;
		}
	}
	
	 
	@JsonSerialize(using = EnumSerializer.class)
	public static enum Status {
		NoCheckIn("待登记"),CheckIn("已登记");

		private String display;
		Status(String display) {
			this.display = display;
		}
		public String getDisplay() {
			return display;
		}
	}

	public Long getPkCheckIn() {
		return pkCheckIn;
	}

	public void setPkCheckIn(Long pkCheckIn) {
		this.pkCheckIn = pkCheckIn;
	}

	public ServicePoint getServicePoint() {
		return servicePoint;
	}

	public void setServicePoint(ServicePoint servicePoint) {
		this.servicePoint = servicePoint;
	}

	public CheckInImplement getCheckInImplement() {
		return checkInImplement;
	}

	public void setCheckInImplement(CheckInImplement checkInImplement) {
		this.checkInImplement = checkInImplement;
	}

	public RoomRegister getRoomRegister() {
		return roomRegister;
	}

	public void setRoomRegister(RoomRegister roomRegister) {
		this.roomRegister = roomRegister;
	}

	public Date getRegisterDate() {
		return registerDate;
	}

	public void setRegisterDate(Date registerDate) {
		this.registerDate = registerDate;
	}

	public Date getCheckInDate() {
		return checkInDate;
	}

	public void setCheckInDate(Date checkInDate) {
		this.checkInDate = checkInDate;
	}

	public Date getCheckOutDate() {
		return checkOutDate;
	}

	public void setCheckOutDate(Date checkOutDate) {
		this.checkOutDate = checkOutDate;
	}

	public CommonUser getOperator() {
		return operator;
	}

	public void setOperator(CommonUser operator) {
		this.operator = operator;
	}

	public Status getStatus() {
		return status;
	}

	public void setStatus(Status status) {
		this.status = status;
	}

	public CheckOutStatus getCheckOutStatus() {
		return checkOutStatus;
	}

	public void setCheckOutStatus(CheckOutStatus checkOutStatus) {
		this.checkOutStatus = checkOutStatus;
	}

	public Integer getVersion() {
		return version;
	}

	public void setVersion(Integer version) {
		this.version = version;
	}

}
